Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft]: Add new record #388

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

[Draft]: Add new record #388

wants to merge 1 commit into from

Conversation

cx1111
Copy link
Member

@cx1111 cx1111 commented Jun 7, 2022

New record class addressing #376, #371.

def read_header(record_name: str) -> RecordInfo:
    """
    Reads a header file, and returns a RecordInfo object containing the
    metadata fields
    """
    # ...Bunch of header parsing logic
    return info

def open_record(record_name: str) -> Record:
    """
    Returns a Record object containing the info read from the header file.
    This can be used to read/write the signals belonging to the record.
    """
    info = read_header(record_name=record_name)
    record = Record(info=info)
    return record

def read_record_data(record_name: str, samp_from: int, samp_to: int):
    """
    The new rdsamp. No streaming. That would be too complicated.
    """
    record = open_record(record_name)  # Does NOT read the signals.
    signals = record.read(samp_from=samp_from, samp_to=samp_to)
    return record.info, signals

Workflow:

  • Read the .hea file to get a RecordInfo object.
  • Create a Record object, and attach the RecordInfo object. (Composition vs inheritance, so no more mixins.)
  • The Record object should contain a SignalHandler object or something similar. This class/object will be responsible for reading/writing the signal data from/to the files. The Record object will contain methods which call the underlying SignalHander object.

@cx1111
Copy link
Member Author

cx1111 commented Jun 10, 2022

I considered having an individual SignalHandler or Signal class for each channel. But I think having one object represent all the channels makes more sense, especially regarding reading/writing multiplexed signal files, ie. a single dat file containing interleaved samples of multiple channels.

It would probably be more difficult to coordinate the logic across a collection of objects. For example, if two signals share the same file, which object(s) should contain the file handler?

@cx1111 cx1111 marked this pull request as draft June 24, 2022 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant